#region Using

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;

using Gizmox.WebGUI.Common;
using Gizmox.WebGUI.Forms;
using System.ComponentModel.Design.Serialization;
using Microsoft.ReportingServices.RdlObjectModel.Serialization;
using System.IO;
using Microsoft.ReportingServices.RdlObjectModel;

#endregion

namespace Bronze.ReportBuilder
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();


            System.ComponentModel.TypeConverter converter = System.ComponentModel.TypeDescriptor.GetConverter(typeof(Point));

            Point point1 = (Point)converter.ConvertFromString("200, 200");
            var pstring=converter.ConvertToString(point1);
            var fontConvert = TypeDescriptor.GetConverter(typeof(Font));
            var font = new System.Drawing.Font("Tahoma", 10F, System.Drawing.FontStyle.Bold);
            var strFont=fontConvert.ConvertToString(font);

            var ct = fontConvert.ConvertTo(font, typeof(InstanceDescriptor));



          


        }



        void GetOrders()
        {
            int[,] indexes = new int[,] {{0, 0 }, { 1, 1 }, { 2, 2 }, { 3, 3 }, { 4, 4 }, { 5, 5 }, { 6, 6 }, { 7, 7 }, { 8, 8 } };

            var dels = new List<int>(){1,2,4,7};
            var results = new List<int>();
           

            System.Action reorder = () =>
            {
                int current = 0;
                for (int i = 0; i < indexes.GetLength(0); i++)
                {
                    if (dels.Contains(indexes[i,1]))
                    {
                        indexes[i, 1] = current-1;
                    }
                    else
                    {
                        current++;
                    }
                }
            };

            reorder();

            for (int i = dels.Count - 1; i >=0; i--)
            {
                var lastIndex = dels[i];
                var resultIdx = indexes[lastIndex, 1]+1;
                results.Add(resultIdx);
                indexes[lastIndex, 1] = resultIdx;
                dels.Remove(lastIndex);
                reorder();
            }
            var s = dels;
        }

        private void Form2_Load(object sender, EventArgs e)
        {
            GetOrders();
        }

        private void button2_Click(object sender, EventArgs e)
        {

        }

        private void button2_Click_1(object sender, EventArgs e)
        {
            Report report;
            using (FileStream fs = File.OpenRead("d:\\sql.rdl"))
            {
                var serializer = new RdlSerializer();
                report = serializer.Deserialize(fs);
            }
            

            //ser.Deserialize()
        }
    }
}